<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
/**
 * 判断页面上的按钮是否可见
 *
 * @param $route
 * @return bool
 * @throws Exception
 */
function is_show($route) {
    $sessionM = new \think\Session();
    $user = $sessionM->get('user');
    if (isset($user['uid']) && ($user['uid'] == 1)) { // 系统管理员，拥有所有权限
        return true;
    }

    $permissionM = new \app\manager\model\PermissionModel();
    $permission_list = $permissionM->getPermissionList();

    if (!in_array($route, $permission_list) && !in_array('/' .$route, $permission_list)) {
        return false; // 跳转到没有权限的提示页，可以自己定制
    }
    return true;
}
